<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>花光马云的钱后台管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../../css/public.css" media="all" />
	<link rel="stylesheet" href="../../css/my.css" media="all" />
	
</head>
<body class="childrenBody">
<form class="layui-form layui-row layui-col-space10">
	<div class="layui-col-md9 layui-col-xs12">
		<div class="layui-row layui-col-space10">
			<div class="layui-col-md12 layui-col-xs12">
				<div class="layui-form-item magt3">
					<label class="layui-form-label required">用户名称</label>
					<div class="layui-input-block">
						<input type="hidden" name="id" value="${user.id}">
						<input type="text" name="uname" value="${user.uname}" class="layui-input newsName" lay-verify="required" placeholder="请输入用户名称">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label required">用户密码</label>
					<div class="layui-input-block">
						<input type="text" name="passwd" value="${user.passwd}" class="layui-input newsName" lay-verify="required" placeholder="请输入用户密码">
					</div>
				</div>	
				
				<div class="layui-form-item">
					<label class="layui-form-label required">用户邮箱</label>
					<div class="layui-input-block">
						<input type="text" name="email" value="${user.email}" class="layui-input newsName" lay-verify="required" placeholder="请输入用户邮箱">
					</div>
				</div>	
				<div class="layui-form-item">
					<label class="layui-form-label required">余额￥</label>
					<div class="layui-input-block">
						<input type="number" name="money" value="${user.money}" class="layui-input newsName" lay-verify="required" placeholder="请输入用户余额">
					</div>
				</div>	
			</div>
		</div>
			<div class="layui-col-md3 layui-col-xs12">
		<blockquote class="layui-elem-quote title magt10"><i class="layui-icon">&#xe609;</i></blockquote>
		<div class="border">
			<div class="layui-form-item">
				<label class="layui-form-label"><i class="layui-icon">&#xe609;</i> 发　布</label>
				<div class="layui-input-block">
					<input type="radio" name="release" title="立即发布" lay-skin="primary" lay-filter="release" checked />
					<input type="radio" name="release" title="定时发布" lay-skin="primary" lay-filter="release" />
				</div>
			</div>
			<div class="layui-form-item layui-hide releaseDate">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="ctime" class="layui-input" id="release" placeholder="请选择日期和时间" readonly />
				</div>
			</div>	
		</div>
	</div>		
	</div>
	<div class="layui-form-item layui-hide">
	 	<input type="button" lay-submit lay-filter="LAY-form-submit" id="LAY-form-submit" value="确认添加">
	    <input type="button" lay-submit lay-filter="LAY-form-edit" id="LAY-form-edit" value="确认编辑">
	</div>
</form>

<script type="text/javascript" src="${path}/layui/layui.js"></script>
<script type="text/javascript" src="${path}/js/commons.js"></script>
<script>
layui.use(['form','layer','layedit','laydate','upload'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        laypage = layui.laypage,
        upload = layui.upload,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;
	
    //格式化时间
    function filterTime(val){
        if(val < 10){
            return "0" + val;
        }else{
            return val;
        }
    }
    //定时发布
    var time = new Date();
    var submitTime = time.getFullYear()+'-'+filterTime(time.getMonth()+1)+'-'+filterTime(time.getDate())+' '+filterTime(time.getHours())+':'+filterTime(time.getMinutes())+':'+filterTime(time.getSeconds());
    laydate.render({
        elem: '#release',
        type: 'datetime',
        trigger : "click",
        done : function(value, date, endDate){
            submitTime = value;
        }
    });    
    form.on("radio(release)",function(data){
        if(data.elem.title == "定时发布"){
            $(".releaseDate").removeClass("layui-hide");
            $(".releaseDate #release").attr("lay-verify","required");
        }else{
            $(".releaseDate").addClass("layui-hide");
            $(".releaseDate #release").removeAttr("lay-verify");
            submitTime = time.getFullYear()+'-'+(time.getMonth()+1)+'-'+time.getDate()+' '+time.getHours()+':'+time.getMinutes()+':'+time.getSeconds();
        }
    });
    
  	//监听提交
	form.on('submit(LAY-form-submit)', function(data) {
  		var index = parent.layer.getFrameIndex(window.name); 
  		$$.ajax({
  			url: '${path}/action/register/save',
  			data: data.field,
  			success: function(json) {
  				parent.layui.table.reload('LAY-table');
  	      		parent.layer.close(index);	
  			}
  		});
	});   

})

</script>
</body>
</html>